package jpa.entity;

import org.springframework.data.domain.Persistable;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by barton on 16-5-9.
 */
@Table(name = "T_USER")
@Entity
@NamedQuery(name = "User.findByFirstName", query = "select u.id from User u where u.firstName=?1")
@NamedStoredProcedureQuery(name = "User.plus1", procedureName = "plus1inout", parameters = {
        @StoredProcedureParameter(mode = ParameterMode.IN, name = "arg", type = Integer.class)
})
public class User implements Serializable, Persistable {
    private String firstName;

    private String lastName;

    @Id
    @GeneratedValue
    private Long id;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Long getId() {
        return id;
    }

    @Override
    public boolean isNew() {
        if (this.id == null)
            return true;
        return false;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {

        return "User:{" +
                "firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
                ", id=" + id +
                '}';
    }
}
